﻿package {	import flash.display.MovieClip;	import flash.events.Event;	public class CpuPaddle extends MovieClip implements IPaddle {		private var easing:int = 7;		private var targetX:Number;		private var ypos:Number;		public var ball:MovieClip;		private var player:MovieClip;		public function CpuPaddle (ypos:Number, paddle:MovieClip) {			addEventListener (Event.ADDED_TO_STAGE, init);			this.y = ypos;			//b = ball;			player = paddle;		}		public function init (evt:Event):void {			removeEventListener (Event.ADDED_TO_STAGE, init);			this.addEventListener (Event.ENTER_FRAME, movePaddle);		}		public function movePaddle (evt:Event):void {			targetX = evt.target.parent.ball.x - this.width / 2;			if (targetX <= 0) {				targetX = 0;			} else if (targetX >= stage.stageWidth - this.width) {				targetX = stage.stageWidth - this.width;			}			this.x += (targetX - this.x) / easing;		}	}}